package com.call.project.web.controller;

import com.call.project.dto.MeetingDto;
import com.call.project.entity.Meeting;
import com.call.project.jni.CInterface;
import com.call.project.utils.ConfigUtils;
import com.call.project.utils.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 Created by IntelliJ IDEA.
 User: wk
 Date: 2017-03-25 下午7:28
 */
@RestController
@RequestMapping("/meeting/")
public class MeetingController {
    @Autowired
    private CInterface cInterface;
    @GetMapping("list")
    public ResponseEntity list() {
        return ResponseEntity.success(ConfigUtils.getMeetingList());
    }

    @GetMapping(value = "close")
    public ResponseEntity closeBtn(MeetingDto meeting) {
        char[] data = new char[1];
        int index  = meeting.getIndex()*12+12+meeting.getButton()*2;
        data[0] = (char) (index);
        cInterface.sendMsg(data);
        data[0] = (char) CInterface.END;
        cInterface.sendMsg(data);
        return ResponseEntity.success(null);
    }


}
